import { request } from "@/utils/http/index";
import { Key } from "react";

import type { hospitalParamType, hospitalReturnType, addHospitalParamsType, updateHospitalParamsType } from "./model/hospitalSetType"

//初始化医院列表请求
export const initHosRequest = ({ page, limit, hosname, hoscode }: hospitalParamType) => {
    return request.get<any, hospitalReturnType>(`/admin/hosp/hospitalSet/${page}/${limit}`, {
        params: {
            hosname,
            hoscode
        }
    })
}
//新增医院请求
export const addHospitalRequest = (data: addHospitalParamsType) => {
    return request.post<any, null>("/admin/hosp/hospitalSet/save", data)
}
//根据id请求更新数据
export const getHospitalFromIdRequest = (id: string) => {
    return request.get<any, hospitalReturnType>(`/admin/hosp/hospitalSet/get/${id}`)
}
//根据id提交更新医院数据
export const updateHosFromIdRequest = (data: updateHospitalParamsType) => {
    return request.put<any, null>("/admin/hosp/hospitalSet/update", data)
}
//删除单个数据请求
export const deleteOneRequest = (id: number) => {
    return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`)
}
//批量删除数据
export const batchDeleteRequest = (ids:Key[]) => {
    return request.delete<any,null>("/admin/hosp/hospitalSet/batchRemove",{data:ids})
}
